/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.produccion.DAO;

import com.produccion.DAO.Interfaces.UsuarioDaoInterface;
import com.produccion.TO.UsuarioTo;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.transform.Transformers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;

/**
 *
 * @author carlosdavid
 */
@Repository
public class UsuarioDao extends HibernateDaoSupport implements UsuarioDaoInterface {
    
    @Autowired
    public UsuarioDao(SessionFactory sessionFactory){
        super.setSessionFactory(sessionFactory);
    }
    
    
    @Override
    public boolean validarUsuario(String idUsuario, String idSede, String clave) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public List<UsuarioTo> ObtenerUsuario(String idUsuario, String idSede) {
        Session session=getHibernateTemplate().getSessionFactory().openSession();
        
        Query consulta=session.createSQLQuery("select clave as clave from Usuario where idUsuario='" + idUsuario + "' and idSede="+idSede).
                setResultTransformer(Transformers.aliasToBean(UsuarioTo.class));
        
    return consulta.list();
    }
    
}
